﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Nature.Toolkit.GMix
{
    public interface IComponent //: IEquatable<IComponent>
    {
        UnitsSet ActualUnits { get; }

        string ComponentName { get; }

        string DisplayName { get; }

        bool IsRoot { get; }

        IEnumerable<ILhs> LhsSet { get; }

        IRhs this[ILhs lhs] { get; }
    }

    public static partial class Extensions
    {
        public static IRhs GetPressureRhs(this IComponent component)
        {
            var query =
                from lhs in component.LhsSet.OfType<ILhsPressure>()
                select component[lhs];
            return query.SingleOrDefault();
        }

        

        public static bool IncludesSpecies(this IComponent component)
        {
            return component.LhsSet.OfType<ILhsSpecies>().Any();
        }

        public static bool RequiresCompressionComputing(this IComponent component)
        {
            return component.LhsSet.Any(i=> i is ILhsTemperatureBase || i is ILhsPressureBase);
        }
    }
}
